package com.marsiot.sdk;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.HashSet;

import com.marsiot.agent.Agent;
import com.marsiot.sdk.MyConfig;

/**
 * @author xiangstudio
 */

public class Client {

    private static Agent agent = new Agent();

    public static void main(String[] args) {
        Properties props = new Properties();
        props.setProperty("command.processor.classname",MyConfig.myCommandProcessor);                  props.setProperty("site.token",MyConfig.mySiteToken);
        props.setProperty("model.name",MyConfig.myModelName);
        props.setProperty("model.description",MyConfig.myModelDescription);
        agent.load(props);

        if (agent.getCommandProcessorClassname() == null) {
            System.out.print("Can't load 'command.processor.classname' \n");
            System.exit(0);
        }

        if (agent.getSiteToken() == null || agent.getSiteToken().length() == 0) {
            System.out.print("Can't load 'site.token' \n");
            System.exit(0);
        }

        try {
            agent.start();
        } catch (Exception e) {
            System.out.print("Unable to start: " + e.getMessage() + "\n");
            System.exit(0);
        }

        System.out.print("Wellcome to " + agent.getMqttHostname() + "\n");
    }
}


